package com.booksys.controller;


import com.booksys.pojo.City;
import com.booksys.result.ResultUtil;
import com.booksys.service.CityService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 图书管理Controller
 */
@RestController
@RequestMapping("/city")
@CrossOrigin
@Api(tags = "全国城市接口")
public class CityController {

    @Autowired
    private CityService cityService;

    /**
     * 获取城市信息
     * @param provinceId
     * @return
     */
    @ApiOperation(value = "获取城市信息")
    @RequestMapping(value = "/selectCities", method={RequestMethod.POST, RequestMethod.GET})
    public ResultUtil<List<City>> selectCities(int provinceId){
        ResultUtil<List<City>> listResultUtil = new ResultUtil<>();
        List<City> list = cityService.getCities(provinceId);
        return listResultUtil.success(list);
    }
}
